package com.mzz.structure.proxy.proxyaop;

import java.lang.reflect.Proxy;

/**
 * 事先不要指定是前置增强还是后置增强,在代码中动态织入切面(考虑中。。。。)
 * @author xushijian
 * @date 18/6/5 下午2:17
 */
public class Test2 {

    public static void main(String[] args) {

//        Calculator calculator = new ProxyFactory<CalculatorImpl>().getProxy(CalculatorImpl.class);
//
//        System.out.println(calculator.calculate(4, 2));

        CalculatorHandler calculatorHandler = new CalculatorHandler(new CalculatorImpl());

        Calculator calculator = (Calculator) Proxy.newProxyInstance(Calculator.class.getClassLoader(), new Class[]{Calculator.class}, calculatorHandler);

        System.out.println(calculator.calculate(100, 2));


    }
}
